package com.fenghongzhang.day006;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class Main4Activity extends AppCompatActivity {
    private SeekBar seek;
    private TextView time;

    private ImageView imageView;

    private boolean bbbb = false;

    private int index = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        time = (TextView) findViewById(R.id.time);
        seek = (SeekBar) findViewById(R.id.seek);
        final LinearLayout ll =  findViewById(R.id.ll);
        imageView = (ImageView) findViewById(R.id.play);

        //换图片的

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ll.setBackgroundColor(Color.parseColor("#888888"));
            }
        });














        seek.setMax(120);
        //把秒格式化显示
        /**
         *  120 / 60  2
         *  34 % 60 34 秒
         */
        seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if(fromUser){
                    time.setText(fmTime(progress));
                }
            }
            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }
            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }
    public String fmTime(int i){
        return i / 60 +":"+i % 60;
    }
}
